package fizzpicks.tetrapulp.tetrapulp;

/**
 * Created by will
 * Date: May 3, 2008 11:36:45 PM
 */

public class LJMusic {
static int dumb_inited;
  int paused;
//  LJVorbis *ogg;
//  DUH *duh;
//  AL_DUH_PLAYER *duhplayer;
};

class LJMusicPlay extends Lockjaw {

LJMusic LJMusic_new() {
  LJMusic m = new LJMusic();

//  m.ogg = null;
//  m.duh = null;
//  m.duhplayer = null;

  return m;
}

void LJMusic_delete(LJMusic m) {
  if (m==null) {
    return;
  }
  LJMusic_unload(m);
  m = null;
}

int LJMusic_load(LJMusic m, String filename) {
  if (m==null || filename==null) {
    return -1;
  }

  LJMusic_unload(m);

/*
  String ext = get_extension(filename);

  if (ext.equals("ogg")) {
    m.ogg = LJVorbis_open(filename);
    return m.ogg != null ? 1 : 0;
  }

  if (!dumb_inited) {
    atexit(dumb_exit);
    dumb_register_stdfiles();
  }
  if (!ustricmp(ext, "it")) {
    m->duh = dumb_load_it_quick(filename);
    return m->duh ? 1 : 0;
  }
  if (!ustricmp(ext, "xm")) {
    m->duh = dumb_load_xm_quick(filename);
    return m->duh ? 1 : 0;
  }
  if (!ustricmp(ext, "s3m")) {
    m->duh = dumb_load_s3m_quick(filename);
    return m->duh ? 1 : 0;
  }
  if (!ustricmp(ext, "mod")) {
    m->duh = dumb_load_mod_quick(filename);
    return m->duh ? 1 : 0;
  }
*/

  return 0;
}

void LJMusic_unload(LJMusic m) {
  if (m == null) {
    return;
  }
  LJMusic_stop(m);

/*
#if LJMUSIC_USING_DUMB
  if (m->duh) {
    unload_duh(m->duh);
    m->duh = NULL;
  }
#endif

#if LJMUSIC_USING_VORBIS
  if (m->ogg) {
    LJVorbis_close(m->ogg);
    m->ogg = NULL;
  }
#endif
*/

}

void LJMusic_setLoop(LJMusic m, int start) {
/*
#if LJMUSIC_USING_VORBIS
  if (m->ogg) {
    LJVorbis_setLoop(m->ogg, start);
  }
#endif
*/
}

void LJMusic_start(LJMusic m, int bufferSize, int vol) {
  if (m == null) {
    return;
  }

  LJMusic_stop(m);

/*
#if LJMUSIC_USING_DUMB
  if (m->duh) {
    m->duhplayer = al_start_duh(m->duh, 2, 0,
                                vol / 256.0,
                                bufferSize,
                                48000);
  }
#endif
#if LJMUSIC_USING_VORBIS
  if (m->ogg) {
    LJVorbis_start(m->ogg, bufferSize, vol, 128);
  }
#endif
*/
  m.paused = 0;
}

void LJMusic_stop(LJMusic m) {
  if (m == null) {
    return;
  }

/*
#if LJMUSIC_USING_DUMB
  if (m->duhplayer) {
    al_stop_duh(m->duhplayer);
    m->duhplayer = NULL;
  }
#endif

#if LJMUSIC_USING_VORBIS
  LJVorbis_stop(m->ogg);
#endif
*/
}

void LJMusic_poll(LJMusic m) {
  if (m == null) {
    return;
  }

/*
#if LJMUSIC_USING_DUMB
  if (m->duhplayer) {
    al_poll_duh(m->duhplayer);
  }
#endif

#if LJMUSIC_USING_VORBIS
  if (m->ogg) {
    LJVorbis_poll(m->ogg);
  }
#endif
*/
}

void LJMusic_pause(LJMusic m, int value) {
  value = value != 0 ? 1 : 0;
  if (m == null) {

  }
/*
  if (WARNINGS && (value == m->paused)) {
    alert("LJMusic_pause", "unchanging.", "", "OK", 0, 13, 0);
    return;
  }
#if LJMUSIC_USING_DUMB
  if (m->duhplayer) {
    if (value) {
      al_pause_duh(m->duhplayer);
    } else {
      al_resume_duh(m->duhplayer);
    }
  }
#endif

#if LJMUSIC_USING_VORBIS
  if (m->ogg) {
    LJVorbis_pause(m->ogg, value);
  }
#endif
*/
  m.paused = value;
}


}
